#include "Log.h"
#include "Config.h"
#include <iostream>

using std::cout;
using std::cerr;

void testLogConfig(const string &filename)
{
    Config cf(filename);
    Config::LogConfig logcf(cf);
    Log::getInstance().init(logcf.log_path, 8192, 1, logcf.max_file_size, logcf.max_file_num);
    // cf.printConfigMap();
    Log::debug("TEST END");
    Log::getInstance().shutdown();
}

int main(int argc, char* argv[])
{
    try
    {
        if (argc < 2)
        {
            cerr << "Need to load a config file\n";
            return 0;
        }
        // 初始化配置
        cout << "初始化配置......\n";
        Config cf(argv[1]);
        Config::LogConfig logcf(cf);
        cout << "初始化日志......\n";
        Log::getInstance().init(logcf.log_path, 8192, 1, logcf.max_file_size, logcf.max_file_num);
        Log::info("日志启动");
        
        cf.printConfigMap();
    }
    catch (const std::exception &e)
    {
        cerr << "error: " << e.what() << "\n";
        Log::getInstance().shutdown();
        return 1;
    }
    // testLogConfig(argv[1]);
    // 初始化配置

    return 0;
}
